<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Home\AuthController;
use App\Http\Controllers\Home\UploadController;
use App\Http\Controllers\Home\UserController;

Route::get('/user', function (Request $request) {
    return $request->user();
})->middleware('auth:sanctum');

//不需要登录就能访问的路由
Route::withoutMiddleware('auth:api')->group(function () {
    //支付测试
    Route::any('test/pay',['App\Http\Controllers\TestController','pay']);
    //微信支付回调通知
    Route::post('pay/wxNotify',['App\Http\Controllers\Pay\WechatController','notify']);
    Route::post('login', [AuthController::class, 'login'])->name('login');
    //获取首页初始化所用信息
    Route::get('homeData', [\App\Http\Controllers\Home\HomeController::class, 'index']);
    //用户注册
    Route::post('register', [UserController::class, 'register']);
    //获取分类
    Route::get('categories',[\App\Http\Controllers\Home\CategoryController::class, 'index']);
});
//获取当前登录用户信息
Route::get('me', [AuthController::class, 'me']);
//退出登录
Route::post('logout', [AuthController::class, 'logout']);
//更新用户信息
Route::put('user', [UserController::class, 'update']);
//图片上传
Route::post('upload/image', [UploadController::class, 'image']);
Route::post('upload/file', [UploadController::class, 'file']);
